package edu.nctu.csie.jichang.database.model.cell;

import edu.nctu.csie.jichang.database.model.datavalue.DataValue;

public class DBRow extends AbstractContainer<DataValue<?>>{

	public DBRow(){
		this("".intern());
	}
	public DBRow(String pName){
		super(pName);
	}
	public String getRowName(){
		return getName();
	}
	public void setRowName(String pName){
		setName(pName);
	}
	public void addCell(String pKey,DataValue<?> pCell){
		addChild(pKey, pCell);
	}
	public DataValue<?>[] getAllCells(){
		return (DataValue[])getChildren().values().toArray();
	}
	public DataValue<?> getCell(String pCell){
		return getChild(pCell);
	}
	public String[] getCellNames(){
		return getAllNames();
	}
	public boolean hasCell(String pName){
		return hasChild(pName);
	}
	public String toString() {
		StringBuffer tOutPut = new StringBuffer();
		tOutPut.append(getName());
		for(String t:getCellNames()){
			tOutPut.append(" [".intern()).append(t.intern()).append(":".intern()).append(getCell(t)).append("];".intern());
		}
		return tOutPut.toString();
	}
}
